<?php
/**
 * Created by PhpStorm.
 * User: jiangxiaobo
 * Date: 2019/11/18 0018
 * Time: 18:55
 */
namespace routes;

use bootstrap\lib\Request;
use bootstrap\lib\traits\Singleton;

class WebConfig extends RoutePredefined
{
    use Singleton;

    protected function configMap()
    {
        return [
            '^\/$' => '\app\http\controllers\Index->index',
            '\/aaa' => '\app\http\controllers\Index->aaa',
        ];
    }

    protected function configSubject()
    {
        return Request::getInstance()->server('REQUEST_URI','');
    }

    protected function check($pattern)
    {
        return preg_match("/{$pattern}/", $this->configSubject());
    }

    protected function getController($route)
    {
        $t = explode("->", $route);
        if(empty($t[1]))
        {
            $t[1] = 'index';
        }
        return [$t[0],$t[1]];
    }
}